//
//  BmlTabBarController.m
//  BeautifulShoppings
//
//  Created by GivenBmli on 16/8/30.
//  Copyright © 2016年 GivenBmli. All rights reserved.
//

#import "BmlTabBarController.h"
#import "TAMacro.h"
#import "GuideViewController.h"
#import "HotViewController.h"
#import "ClassificationViewController.h"
#import "MineViewController.h"
@interface BmlTabBarController ()

@end

@implementation BmlTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatTabBar];
    
}

- (void)creatTabBar {
    GuideViewController *guide = [[GuideViewController alloc]init];
    [self addChildVc:guide Title:@"指南" Image:@"zhinan2"SeleImage:@"zhinan"];
    
    HotViewController *hot = [[HotViewController alloc]init];
    [self addChildVc:hot Title:@"热门" Image:@"remen2"SeleImage:@"remen"];
    
    ClassificationViewController *classification = [[ClassificationViewController alloc]init];
    [self addChildVc:classification Title:@"分类" Image:@"fenlei2"SeleImage:@"fenlei"];
    
    MineViewController *mine = [[MineViewController alloc]init];
    [self addChildVc:mine Title:@"我的" Image:@"wod2" SeleImage:@"wod"];
 
}

-(void)addChildVc:(UIViewController *)childVC
            Title:(NSString *)title
            Image:(NSString *)image
        SeleImage:(NSString *)seleImage{
    
    
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:childVC];
    childVC.title = title;
    childVC.tabBarItem.image = [UIImage imageNamed:image];
    // [self addChildViewController:nav];
    
    
    childVC.tabBarItem.selectedImage = [[UIImage imageNamed:seleImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UIView *bgView = [[UIView alloc] initWithFrame:self.tabBar.bounds];
    
    [bgView jxl_setDayMode:^(UIView *view) {
        bgView.backgroundColor = [UIColor whiteColor];
    } nightMode:^(UIView *view) {
        bgView.backgroundColor = [UIColor grayColor];
        
        
    }];
    
    [self.tabBar insertSubview:bgView atIndex:0];
    self.tabBar.opaque = YES;
    
    
    NSMutableDictionary *dic1 = [NSMutableDictionary dictionary];
    
    dic1[NSForegroundColorAttributeName] =  [UIColor grayColor];
    
    NSMutableDictionary *dic2 = [NSMutableDictionary dictionary];
    dic2[NSForegroundColorAttributeName]= [UIColor redColor];
    
    [childVC.tabBarItem setTitleTextAttributes:dic1 forState:UIControlStateNormal];
    
    [childVC.tabBarItem setTitleTextAttributes:dic2 forState:UIControlStateSelected];
    [self addChildViewController:nav];
    
    // 取消文字的渲染蓝色效果
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
